package com.example.chenz.simpleplay;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button startButton = (Button)findViewById(R.id.startButton);
        startButton.setOnClickListener(startIt);
        Button stopButton = (Button)findViewById(R.id.stopButton);
        stopButton.setOnClickListener(stopIt);
    }

    private OnClickListener startIt = new OnClickListener() {
        @Override
        public void onClick(View v) {
            startService(new Intent("com.studio.android.START_AUDIO_SERVICE"));
        }
    };

    private OnClickListener stopIt = new OnClickListener() {
        @Override
        public void onClick(View v) {
            stopService(new Intent("com.studio.android.START_AUDIO_SERVICE"));
            finish();
        }
    };
}
